# 硬件UDP通信SDK Makefile

.PHONY: all build test clean run-examples help

# 默认目标
all: build test

# 构建项目
build:
	@echo "构建项目..."
	@go build -v ./sdk/...
	@echo "构建完成"

# 运行测试
test:
	@echo "运行测试..."
	@go test -v ./sdk/...
	@echo "测试完成"

# 运行协议测试
test-protocol:
	@echo "运行协议测试..."
	@go run examples/protocol_demo.go

# 运行简单客户端示例
run-simple:
	@echo "运行简单客户端示例..."
	@go run examples/simple_client.go

# 运行硬件客户端示例
run-hardware:
	@echo "运行硬件客户端示例..."
	@go run examples/hardware_client.go

# 运行批量发送示例
run-batch:
	@echo "运行批量发送示例..."
	@go run examples/batch_sender.go

# 启动测试服务器
start-server:
	@echo "启动测试服务器..."
	@go run examples/test_server.go

# 格式化代码
fmt:
	@echo "格式化代码..."
	@go fmt ./sdk/...
	@echo "格式化完成"

# 代码检查
vet:
	@echo "代码检查..."
	@go vet ./sdk/...
	@echo "检查完成"

# 清理构建文件
clean:
	@echo "清理构建文件..."
	@go clean ./sdk/...
	@echo "清理完成"

# 安装依赖
deps:
	@echo "安装依赖..."
	@go mod tidy
	@echo "依赖安装完成"

# 生成文档
doc:
	@echo "生成文档..."
	@go doc -all ./sdk
	@echo "文档生成完成"

# 运行所有示例
run-examples: test-protocol run-simple

# 完整检查 (格式化 + 检查 + 测试)
check: fmt vet test

# 帮助信息
help:
	@echo "可用的命令:"
	@echo "  build         - 构建项目"
	@echo "  test          - 运行测试"
	@echo "  test-protocol - 运行协议测试"
	@echo "  run-simple    - 运行简单客户端示例"
	@echo "  run-hardware  - 运行硬件客户端示例"
	@echo "  run-batch     - 运行批量发送示例"
	@echo "  start-server  - 启动测试服务器"
	@echo "  fmt           - 格式化代码"
	@echo "  vet           - 代码检查"
	@echo "  clean         - 清理构建文件"
	@echo "  deps          - 安装依赖"
	@echo "  doc           - 生成文档"
	@echo "  run-examples  - 运行所有示例"
	@echo "  check         - 完整检查 (格式化 + 检查 + 测试)"
	@echo "  help          - 显示此帮助信息"